<template>
  <div class="tu">
    <van-nav-bar
        title="我的发布"
        left-text="返回"
        left-arrow
        fixed
        @click-left="onClickLeft"
    />
  </div>
  <!--  我的发布房源-->
  <div class="publish">
<!--    图片-->
    <div class="fang">
      <van-image
          width="100"
          height="100"
          :src="rent.picture"
      />
<!--      房子位子-->
      <div class="address">
        <h4>{{rent.address}}</h4>
      </div>
<!--      介绍-->
      <div class="jie">
        <span class="hj">{{rent.houseArea}}平方 {{rent.houseStar}}</span>
      </div>
<!--      价格-->
      <div class="jiage">
        <h5>{{rent.houseRent}}元/月</h5>
      </div>
    </div>
  </div>
  <!--    按钮-->
  <div class="xia">
    <div class="xia1">每个用户仅限上传一个房源</div>
    <!--      12按钮-->
    <div class="an">
      <div class="an1">
        <van-button color="black" size="small" class="hhh" @click="deleteOne">下架</van-button>
      </div>
      <div class="an2">
        <van-button color="black" size="small" class="hhh">分享房源</van-button>
      </div>
    </div>
  </div>
  <hr>
  <div class="two" @click="iss">
    <h3>发布房源</h3>
  </div>
</template>

<script setup>
//点击进来钩子函数查询并赋值
import {ref ,onMounted} from 'vue';
import {get,post} from '../../util/request.js'
import {useStore} from '../../pinia/index.js'
import axios from "axios";
const store=useStore()
const rent =ref({})

// //test 钩子函数
onMounted(()=>{
  axios({
    method:'get',
    url:"http://39.106.55.36:9099/my/selectOne",
  }).then((res) => {
   rent.value=(res.data.data)
  }).catch((err)=>{
    console.log("((((((((((((((")
  })
})
//xia  jia
// dId.value=rent.value.id
const deleteOne = () => {

  console.log(rent.value.id)
  axios({
    method:'get',
    url:"http://39.106.55.36:9099/my/deleteOne",
    params:{
      id:rent.value.id
    }
  }).then((res) => {
    rent.value=(res.data.data)
  }).catch((err)=>{
    console.log("((((((((((((((")
  })

}
const onClickLeft = () => history.back();
//d点击跳到发布界面
import {useRouter} from "vue-router";

const router = useRouter();
const iss = () => {
  router.push("/issue")
}
</script>

<style scoped>
.hhh{
  width: 80px;
  height: 30px;
}
/*我的发布*/
.publish {
  position: absolute;
  top: 55px;
  left: 15px;
  width: 400px;
  height: 156px;
  border: 1px solid #888888;
  border-radius: 5px;
}
.fang{
  margin-left: -299px;
}
.address{
  position: absolute;
  top: 0px;
  left: 109px;
  width: auto;
  text-align: left;

}
.jie{
  position: absolute;
  top: 74px;
  left: 109px;
  width: 214px;
  text-align: left;
}
.jiage{
  position: absolute;
  top: 76px;
  left: 321px;
  width: 75px;
}
.xia{
  position: absolute;
  top: 171px;
  left: 15px;
  width: 75px;
}
.hj,.xia1{
  color: #9d9d9d;
}
.xia1{
  text-align: left;
  margin-top: 5px;
  position: absolute;
  width: 198px;
  height: 32px;
}
.an{
  position: absolute;
  width: 198px;
  height: 32px;
  left: 209px;
}
.an1{
  position: absolute;
}
.an2{
  position: absolute;
  left: 99px;
}
.two {
  padding-top: 5px;
  width: 400px;
  height: 33px;
  position: absolute;
  top: 830px;
  left: 15px;
  background-color: #1a1a1a;
}
h4{
  margin: auto;
}
h5{
  margin: auto;
}
h3 {
  color: #dbd3d3;
  margin: auto;
}
p{
  margin: auto;
  color: #ab2626;
}
</style>
